package com.app.configuration.web.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.app.util.common.HandlerResult;
import com.app.util.common.ResponseUtil;


/**
 * 404错误配置，当直接输入不存在的地址
  * 配置错误页面
 * chenl
 */
@Controller
public class Error404PageConfig implements ErrorController{

	@RequestMapping("/error")
    public void error(HttpServletRequest request ,HttpServletResponse response){
		//System.out.println("-------------1111111111111");
		HandlerResult result = new HandlerResult();
		result.setCode(1);
     	result.setMessage("404");
     	
     	ResponseUtil.writeJson(result, response);
    }

	@Override
	public String getErrorPath() {
		// TODO Auto-generated method stub
		//System.out.println("-------------22222");
		return "/error";
	}
    

}

